package com.yunhe.spring.struts.interceptors;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class SessionInterceptor extends MethodFilterInterceptor{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
	Map<String, Object> session=invocation.getInvocationContext().getSession();
		if(session.get("user")==null){
			return "error";
		}
		System.out.println("回话拦截器开始拦截");
		String result=invocation.invoke();
		System.out.println("会话拦截器结束拦截");
		return result;
	}

}
